package com.ljc.gld;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();//敌人的数量
        int k = scanner.nextInt(); //装弹时间
        //愉悦度
        int[] arr = new int[n];
        for(int i = 0 ; i < n ; i++){
            arr[i] = scanner.nextInt();
        }
        int result = arr[0];
        int temp = 4;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] < arr[i+1]){
                continue;
            }
            temp--;
            result+=arr[i];
            if(temp == 0){
                i+=k;
            }
        }
        System.out.println(result);
    }
}
